﻿using System;
using System.Xml.Linq;
using FluentlyXml.Core.Serialization;

namespace FluentlyXml.Core.BuiltInSerializers
{
	internal class CustomSerializerForAllDerivedTypes : CustomSerializer
	{
		public CustomSerializerForAllDerivedTypes(Type appliesToType)
			: base(appliesToType)
		{
		}

		public override bool CanSerialize(Type type)
		{
			return AppliesToType.IsAssignableFrom(type);
		}

		public override XElement Serialize(Type type, object obj, ISerializationContext context)
		{
			return base.Serialize(AppliesToType, obj, context);
		}
	}
}